﻿<UserControl x:Class="SoftTeach.View.Personen.SchülerlisteWorkspaceView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:softTeach="clr-namespace:SoftTeach"
             xmlns:personen="clr-namespace:SoftTeach.View.Personen" xmlns:personen1="clr-namespace:SoftTeach.ViewModel.Personen"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="800">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="250"/>
      <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid Grid.Column="0">
      <Grid Grid.Row="1">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal">
          <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Command="{Binding Path=AddSchülerlisteCommand}" 
                    ToolTip="Neue Schülerliste erstellen">
            <StackPanel Orientation="Horizontal">
              <Grid>
                <Image Source="/SoftTeach;component/Images/Schülerliste32.png"/>
                <Image Source="/SoftTeach;component/Images/AddOverlay32.png"/>
              </Grid>
            </StackPanel>
          </Button>
          <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                    Command="{Binding Path=DeleteSchülerlisteCommand}" 
                    ToolTip="Aktuelle Schülerliste löschen.">
            <StackPanel Orientation="Horizontal">
              <Grid>
                <Image Source="/SoftTeach;component/Images/Schülerliste32.png"/>
                <Image Source="/SoftTeach;component/Images/RemoveOverlay32.png"/>
              </Grid>
            </StackPanel>
          </Button>
          <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                    Command="{Binding Path=MoveSchülerlisteCommand}" 
                    ToolTip="Aktuelle Schülerliste ins nächste Jahr übernehmen.">
            <StackPanel Orientation="Horizontal">
              <Grid>
                <Image Source="/SoftTeach;component/Images/Schülerliste32.png"/>
                <Image Source="/SoftTeach;component/Images/MoveOverlay32.png"/>
              </Grid>
            </StackPanel>
          </Button>
        </StackPanel>
        <GroupBox Grid.Row="1" Header="Filtern" Margin="4,0,4,0">
          <Grid>
            <Grid.RowDefinitions>
              <RowDefinition/>
              <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="60"/>
              <ColumnDefinition/>
              <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Label Grid.Row="0" Grid.Column="0" Padding="3" VerticalAlignment="Center">Schuljahr</Label>
            <ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Jahrtypen}"
                              SelectedValue="{Binding Path=JahrtypFilter}" 
                              SelectedValuePath="." 
                              DisplayMemberPath="JahrtypBezeichnung"
                        Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"
                      HorizontalAlignment="Stretch"/>
            <Button Grid.Row="0" Grid.Column="2" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                Command="{Binding Path=ResetJahrtypFilterCommand}">
              <Image Source="/SoftTeach;component/Images/Remove16.png"/>
            </Button>
            <Label Grid.Row="1" Grid.Column="0" Padding="3" VerticalAlignment="Center">Fach</Label>
            <ComboBox Grid.Row="1" Grid.Column="1" MinWidth="100" ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Fächer}"
                              SelectedValue="{Binding Path=FachFilter}" 
                              SelectedValuePath="." 
                              DisplayMemberPath="FachBezeichnung"
                        Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"
                                          HorizontalAlignment="Stretch"/>
            <Button Grid.Row="1" Grid.Column="2" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                Command="{Binding Path=ResetFachFilterCommand}">
              <Image Source="/SoftTeach;component/Images/Remove16.png"/>
            </Button>
          </Grid>
        </GroupBox>
        <DataGrid Grid.Row="2"  Margin="5" SelectedItem="{Binding Path=CurrentSchülerliste, Mode=TwoWay}" 
                    IsReadOnly="True"
                    ItemsSource="{Binding Path=SchülerlistenView}" AutoGenerateColumns="False" >
          <DataGrid.Columns>
            <DataGridComboBoxColumn 
                        Header="Schuljahr" 
                        ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Jahrtypen}"
                        SelectedItemBinding="{Binding Path=SchülerlisteJahrtyp}" 
                        DisplayMemberPath="JahrtypKurzbezeichnung" SortMemberPath="SchülerlisteJahrtyp.JahrtypBezeichnung"
                        EditingElementStyle="{StaticResource DatagridComboBoxElementStyle}"/>
            <DataGridComboBoxColumn 
                        Header="Fach" 
                        ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Fächer}"
                        SelectedItemBinding="{Binding Path=SchülerlisteFach}" 
                        DisplayMemberPath="FachKurzbezeichnung" SortMemberPath="SchülerlisteFach.FachBezeichnung"
                        EditingElementStyle="{StaticResource DatagridComboBoxElementStyle}"/>
            <DataGridComboBoxColumn 
                        Header="Klasse" 
                        ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Klassen}"
                        SelectedItemBinding="{Binding Path=SchülerlisteKlasse}" 
                        DisplayMemberPath="KlasseBezeichnung" SortMemberPath="SchülerlisteKlasse.KlasseBezeichnung"
                        EditingElementStyle="{StaticResource DatagridComboBoxElementStyle}"/>
          </DataGrid.Columns>
        </DataGrid>
      </Grid>
    </Grid>
    <Grid Grid.Column="1">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <ContentControl Grid.Row="1" Content="{Binding Path=CurrentSchülerliste}">
        <ContentControl.Resources>
          <DataTemplate DataType="{x:Type personen1:SchülerlisteViewModel}">
            <personen:SchülerlisteDetailView />
          </DataTemplate>
        </ContentControl.Resources>
      </ContentControl>
    </Grid>
  </Grid>
</UserControl>
